package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.MerchantPledgeTaskCollectionConf;
import com.sc.nft.mapper.MerchantPledgeTaskCollectionConfMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 商户质押任务质押藏品表(sc_merchant_pledge_task_collection_conf)数据DAO
 *
 * @author Sun
 * @since 2023-11-06 13:36:14
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class MerchantPledgeTaskCollectionConfDao extends ServiceImpl<MerchantPledgeTaskCollectionConfMapper, MerchantPledgeTaskCollectionConf> {

    public List<MerchantPledgeTaskCollectionConf> getListByTaskConfId(Long id) {
        LambdaQueryWrapper<MerchantPledgeTaskCollectionConf> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MerchantPledgeTaskCollectionConf::getTaskConfId, id);
        return list(wrapper);
    }

    public MerchantPledgeTaskCollectionConf getListByTaskConfIdAndCollectionId(Long id, Long collectionId) {
        LambdaQueryWrapper<MerchantPledgeTaskCollectionConf> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MerchantPledgeTaskCollectionConf::getTaskConfId, id);
        wrapper.eq(MerchantPledgeTaskCollectionConf::getCollectionId, collectionId);
        wrapper.last("order by id desc limit 1");
        return getOne(wrapper);
    }
}